<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>子串能表示从 1 到 N 数字的二进制串</title>
</head>
<body>
  <script>
    function fn(S, N) {
      let i = 0;
      while (++i <= N) {
        if (S.indexOf(i.toString(2)) === -1) return false;
      }
      return true;
    }
    console.log(fn('0110', 3))
  </script>
</body>
</html>